﻿using System;
using System.Collections;
using System.Collections.ObjectModel;
using System.Collections.Specialized;
using System.Collections.Generic;
using System.ComponentModel;
using CM = System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using CDA = System.ComponentModel.DataAnnotations;
using System.Data;
using System.Data.SqlClient;
using System.Data.Linq;
using System.Data.Linq.Mapping;
using System.Linq;
using System.Linq.Dynamic;
using System.Linq.Expressions;
using System.Reflection;
using System.Text.RegularExpressions;
using System.Xml;
using System.Xml.Linq;
using System.Web;
using System.Web.DynamicData;
using SWD = System.Web.DynamicData;
using System.Web.UI.WebControls;
using Dimok;

namespace Data.LINQ {

	using System;
	using System.Collections.Generic;
	using System.ComponentModel.DataAnnotations;
	using DAs = System.ComponentModel.DataAnnotations;
	using System.Runtime.Serialization;

	#region Partials
	#region MotoBankDataContext

	////////////////////////////////////////////////////////////////////////////////////////////////////
	/// <summary>	Moto bank data context. </summary>
	///
	/// <remarks>	Dimon, 12/21/2010. </remarks>
	////////////////////////////////////////////////////////////////////////////////////////////////////

	public partial class MotoBankDataContext {
		public string GetEntityTableName<TEntity>() where TEntity : class {
			var props = TypeDescriptor.GetProperties(typeof(MotoBankDataContext));
			foreach (PropertyDescriptor prop in props)
				if (GetTable<TEntity>().GetType() == prop.PropertyType)
					return prop.Name;
			throw new NotImplementedException(typeof(TEntity).Name + " does not have a related table property.");
		}

	}
	#endregion

	#region v_CustomerFile_Export_List

	////////////////////////////////////////////////////////////////////////////////////////////////////
	/// <summary>	List of v customer file exports. </summary>
	///
	/// <remarks>	Dimon, 12/21/2010. </remarks>
	////////////////////////////////////////////////////////////////////////////////////////////////////

	[MetadataType(typeof(v_CustomerFile_Export_ListMetaData))]
	public partial class v_CustomerFile_Export_List {
		public static string DefaultFilter(string Filter) {
			return Filter + "" == "" ? "1 = 0" : Filter;
		}
		public static string DefaultSort(string OrderBy) {
			return OrderBy + "" == "" ? "LoanID" : OrderBy;
		}
	}

	////////////////////////////////////////////////////////////////////////////////////////////////////
	/// <summary>	V customer file export list meta data. </summary>
	///
	/// <remarks>	Dimon, 12/21/2010. </remarks>
	////////////////////////////////////////////////////////////////////////////////////////////////////

	[SelectTable()]
	[UpdateTable(typeof(v_CustomerFile_Update))]
	public class v_CustomerFile_Export_ListMetaData {
		[SortField(0), DefaultField(1)]
		[ClientKey]
		public object UsixID;
		[DefaultField(0)]
		[ClientKey]
		public object LoanID;
		[DefaultField(1)]
		[ClientKey]
		public object CompanyID_Raw;
		[DisplayFormat(DataFormatString = "{0:n}")]
		[DisplayName("DoC")]
		public bool DoCollect { get; set; }
		[DisplayFormat(DataFormatString="{0:MM/dd/yyyy}")]
		public object Open_Date;
		[DisplayName("GL_Days")]
		public int G_L_Date { get; set; }
		[DisplayName("St")]
		[HtmlTitle("Customer State")]
		public string St { get; set; }
		[DisplayName("CstZip")]
		public string Zip_Code { get; set; }
		[DisplayName("PS"), HtmlTitle("Payment Schedule (M,S,B,W)")]
		public string Pymnt_Schedule { get; set; }
		[DisplayName("#Pmts"), HtmlTitle("Total number of payments")]
		public int __of_Payments { get; set; }
		[DisplayName("PM"), HtmlTitle("Payments Made(Monthly)")]
		public System.Decimal __of_PaymentsM { get; set; }
		[DisplayName("Pmt")]
		public System.Decimal Payment_Amount { get; set; }
		[DisplayName("Ttl.Pmts")]
		public System.Decimal Total_Payments { get; set; }
		[DisplayName("FPD")]
		public System.DateTime _1st__Payment_Date { get; set; }
		[DisplayName("FPDR"), HtmlTitle("1st Payment Date - Real")]
		public System.DateTime FirstPaymentDateCalc { get; set; }
		[DisplayName("LPD")]
		public System.DateTime Last_Payment_Date { get; set; }
		[DisplayName("NPD")]
		public System.DateTime Next_Payment_Date { get; set; }
		[DisplayName("PR(R)")]
		public System.Decimal __Pmts_Remaining { get; set; }
		[DisplayName("PR"), HtmlTitle("Payments Remaining (Monthly)")]
		public System.Decimal __Pmts_RemainingM { get; set; }
		[DisplayName("Balance")]
		public System.Decimal Balance_Remaining { get; set; }
		[DisplayName("SC")]
		public System.String Status_Code { get; set; }
		[DisplayName("U"), DefaultField(2), HtmlTitle("CompanyID:1 - AFC,2 - BQ, 4 - AFC, 5 - SF")]
		public int CompanyID { get; set; }
		[DisplayName("BK")]
		public System.String Bankruptcy_Filed_Y_N_ { get; set; }
		[DisplayName("BKType")]
		public System.String Bankruptcy_Type_07_13_ { get; set; }
		[DisplayName("!Principal"), HtmlTitle("Calculated Principal (Simple&amp;Rule78)")]
		public System.Decimal Total_Principal { get; set; }
		[DisplayName("PDP")]
		public System.Decimal PastDuePayments { get; set; }
		[DisplayName("$PDA")]
		public System.Decimal PastDueAmount { get; set; }
		[DisplayName("PM"), HtmlTitle("Payments Made (Monthly)")]
		public System.Decimal PaymentsMadeM { get; set; }
		[DisplayName("PE"), HtmlTitle("Payments Expected (Monthly)")]
		public System.Decimal PaymentsExpectedM { get; set; }
		[DisplayName("PB"), HtmlTitle("Payments Behind (Monthly)")]
		public System.Decimal PaymentsBehindM { get; set; }
		[DisplayName("Title")]
		public System.String Title_Received_Y_N_ { get; set; }
		[DisplayName("DDS"), HtmlTitle("Collection DueDate Since")]
		public System.Int32 DueDateSince { get; set; }
		[DisplayName("CP")]
		public System.Int32 DateDueBy_Priority { get; set; }
		[DisplayName("DAH")]
		public System.Int32 DueAfterHour { get; set; }
		[DisplayName("CollectBy")]
		public System.String DateDueBy { get; set; }
		[DisplayName("DPTP")]
		public System.Int32 DaysToPTP_Real { get; set; }
		[DisplayName("DPTP(S)")]
		public System.Int32 DaysToPTP_Sort { get; set; }
		[DisplayName("LT"), HtmlTitle("Loan Type - Simple_Add_On(S1,A1)")]
		public System.String Simple_Add_On { get; set; }
		[DisplayName("VC")]
		public System.Boolean VINCheck { get; set; }
	}
	#endregion

	#region v_Note

	////////////////////////////////////////////////////////////////////////////////////////////////////
	/// <summary>	V note. </summary>
	///
	/// <remarks>	Dimon, 12/21/2010. </remarks>
	////////////////////////////////////////////////////////////////////////////////////////////////////

	[MetadataType(typeof(v_NoteMetaData))]
	public partial class v_Note { }

	////////////////////////////////////////////////////////////////////////////////////////////////////
	/// <summary>	V note meta data. </summary>
	///
	/// <remarks>	Dimon, 12/21/2010. </remarks>
	////////////////////////////////////////////////////////////////////////////////////////////////////

	[SelectTable(false)]
	[DeleteTable(typeof(t_Note))]
	public class v_NoteMetaData {
		[ClientKey]
		public object ID;
		[HtmlTitle("Message Icon"), DisplayName(" ")]
		[DefaultField(0), DisplayFormat(DataFormatString = "<img src='/images/{0}'>")]
		public object NoteTypeIconURL { get; set; }
		[DefaultField(1), DisplayFormat(DataFormatString = "<textarea style='display:none'>{0}</textarea><div onmouseover='InitNoteHover(this,this.previousSibling.value)'  style='white-space:pre;width:250px;height:1em;overflow:hidden;border:solid 0px navy;cursor:hand' onclick='event.cancelBubble=true' onfocus='bridgeNotes.showNote(this)' onblur='bridgeNotes.showNote(this,true)'>{0}</div>")]
		public object Note;
		[DefaultField(1), DisplayName("Type")]
		public object NoteTypeNick { get; set; }
		[DefaultField(2), DisplayName("Action")]
		public object NoteActionCodeNick { get; set; }
		[DefaultField(3), DisplayName("Result")]
		public object StatusNick { get; set; }
		[DisplayFormat(DataFormatString = "{0:MM/dd/yy HH:mm}")]
		public object NoteDate { get; set; }
		[DisplayName("NoteDay"), DefaultField(4)]
		[DisplayFormat(DataFormatString = "{0:MM/dd/yy}")]
		public object NoteDate0 { get; set; }
		[DisplayName("NoteTime")]
		[DisplayFormat(DataFormatString = "{0:HH:mm}")]
		public object NoteDate1 { get; set; }
		[DefaultField(5)]
		public object NoteUser { get; set; }
		[DefaultField(5), DisplayName("Collect By")]
		public object DateDueBy { get; set; }
	}
	#endregion

	#region v_UploadInfo

	////////////////////////////////////////////////////////////////////////////////////////////////////
	/// <summary>	Information about the v upload. </summary>
	///
	/// <remarks>	Dimon, 12/21/2010. </remarks>
	////////////////////////////////////////////////////////////////////////////////////////////////////

	[MetadataType(typeof(v_UploadInfoMetData))]
	public partial class v_UploadInfo { }

	////////////////////////////////////////////////////////////////////////////////////////////////////
	/// <summary>	V upload information met data. </summary>
	///
	/// <remarks>	Dimon, 12/21/2010. </remarks>
	////////////////////////////////////////////////////////////////////////////////////////////////////

	[UpdateTable(typeof(t_UploadInfo))]
	[DeleteTable]
	[InsertTable]
	[SelectTable(true)]
	public class v_UploadInfoMetData {
		[ClientKey]
		public object ID;
		[DisplayName("Holder")]
		[DefaultField(0)]
		[EditColumnTemplate(typeof(v_ContractHolder), typeof(t_UploadInfo), LookUpFieldName = "ContractHolderID", LookUpTextField = "Nick")]
		public string ContractHolderNick { get; set; }
		[EditColumnTemplate]
		[DefaultField(3)]
		public string Code;
		[EditColumnTemplate(typeof(t_Company), typeof(t_UploadInfo), LookUpFieldName = "CompanyID")]
		[DisplayName("Company")]
		[DefaultField(1)]
		public string CompanyName { get; set; }
		[SortField(0, SortDirection.Descending)]
		[DefaultField(2)]
		[EditColumnTemplate]
		public object Date;
		[DefaultField(4)]
		[DisplayName("#")]
		public object UploadsCount { get; set; }
	}
	#endregion

	#region v_Upload

	////////////////////////////////////////////////////////////////////////////////////////////////////
	/// <summary>	V upload. </summary>
	///
	/// <remarks>	Dimon, 12/21/2010. </remarks>
	////////////////////////////////////////////////////////////////////////////////////////////////////

	[MetadataType(typeof(v_UploadMetaData))]
	public partial class v_Upload {
		public int CarAge { get { return DateTime.Now.Year - (int)this.Car_Year + (DateTime.Now.Month > 8 ? 1 : 0); } }
	}

	////////////////////////////////////////////////////////////////////////////////////////////////////
	/// <summary>	V upload meta data. </summary>
	///
	/// <remarks>	Dimon, 12/21/2010. </remarks>
	////////////////////////////////////////////////////////////////////////////////////////////////////

	[DeleteTable(typeof(v_Upload_Update)), SelectTable(false),UpdateTable()]
	public partial class v_UploadMetaData {
		[DisplayName("VIN")]
		[DefaultField(1)]
		[EditColumnTemplate]
		public object Serial_ { get; set; }
		[SortField(0)]
		[DefaultField(0)]
		[ClientKey]
		public object ID;
		[DefaultField(2)]
		public object Primary_SSN;
		[DefaultField(3)]
		public object First_Name;
		[DefaultField(4)]
		public object Last_Name;
		[DefaultField(5)]
		public object Full_Name;
		[DisplayName("Value")]
		public object BookValue { get; set; }
		[DisplayName("BVD")]
		[HtmlTitle("Book Value Type")]
		public object BookProviderValueTypeName { get; set; }
		[DisplayName("VC")]
		[DisplayFormat(DataFormatString = "<img src='/images/buttons/VIN_{0}.gif' />")]
		public object VinCheck { get; set; }
		[DisplayName("BP")]
		public object BookProviderCode { get; set; }
		[DisplayFormat(DataFormatString = "{0:MM/dd/yyyy}")]
		[DisplayName("1stPD")]
		public object _1st__Payment_Date { get; set; }
		[EditColumnTemplate(typeof(ts_LoanPaymentType), typeof(v_Upload), LookUpFieldName = "Pmt_Freq", LookUpTextField="Code", LookUpValueField = "PaymentsPerYear", IsEditAll = true)]
		public object Pmt_Freq { get; set; }
		[DisplayName("IT")]
		[EditColumnTemplate(typeof(ts_InterestType), typeof(v_Upload), LookUpFieldName = "InterestTypeID",IsEditAll=true)]
		public object InterestTypeCode { get; set; }
		[DisplayName("#Pmts")]
		[HtmlTitle("Number of Payments")]
		public object @__of_Payments { get; set; }
		[DisplayName("PM")]
		[HtmlTitle("Payments Made")]
		public object __Pmts_Md { get; set; }
		[DisplayName("PR")]
		[HtmlTitle("Payments Remaining")]
		public object __Pmts_Remaining { get; set; }
		[DisplayName("#Pmts!")]
		[HtmlTitle("Number of Payments (Mos)")]
		public object NumberOfPaymentsM { get; set; }
		[DisplayName("PM!")]
		[HtmlTitle("Payments Made (Mos)")]
		public object PaymentsMadeM { get; set; }
		[DisplayName("PR!")]
		[HtmlTitle("Payments Remaining (Mos)")]
		public object PaymentsRemainingM { get; set; }
		[EditColumnTemplate]
		public object APR{ get; set; }
		[DisplayName("PM%")]
		public object PaymentsMadePercent { get; set; }
		[EditColumnTemplate(IsEditAll = true)]
		[DisplayName("Tr")]
		public object Tier { get; set; }
		[EditColumnTemplate(IsEditAll=true)]
		[DisplayName("Rs")]
		public object Recourse { get; set; }
		[DisplayName("DPID")]
		[EditColumnTemplate(IsEditAll = true)]
		public System.Nullable<int> DecisionProgramID { get; set; }
		[EditColumnTemplate(IsEditAll = true)]
		public System.Nullable<decimal> DecisionPrice { get; set; }

	}
	#endregion

	#region v_PurchaseBatch

	////////////////////////////////////////////////////////////////////////////////////////////////////
	/// <summary>	V purchase batch. </summary>
	///
	/// <remarks>	Dimon, 12/21/2010. </remarks>
	////////////////////////////////////////////////////////////////////////////////////////////////////

	[MetadataType(typeof(v_PurchaseBatchMedaData))]
	public partial class v_PurchaseBatch { }

	////////////////////////////////////////////////////////////////////////////////////////////////////
	/// <summary>	V purchase batch meda data. </summary>
	///
	/// <remarks>	Dimon, 12/21/2010. </remarks>
	////////////////////////////////////////////////////////////////////////////////////////////////////

	[UpdateTable(typeof(t_PurchaseBatch)), InsertTable, DeleteTable, SelectTable(true)]
	public class v_PurchaseBatchMedaData {
		[ClientKey]
		public object ID;
		[DisplayName("Holder")]
		[DefaultField(0)]
		[EditColumnTemplate(typeof(v_ContractHolder), typeof(v_PurchaseBatch), LookUpFieldName = "ContractHolderID", LookUpTextField = "Nick")]
		public object ContractHolderNick { get; set; }
		[EditColumnTemplate(Template = JQueryEditTemplates.dropdown, LookUpFieldName = "StatusID", IsAdd = false)]
		[DefaultField(4)]
		public int Status;
		[DisplayFormat(DataFormatString = "{0:MM/dd/yyyy}")]
		public int StatusDate;
		[EditColumnTemplate(typeof(t_Company), typeof(v_PurchaseBatch), LookUpFieldName = "CompanyID", LookUpValueField = "ID", LookUpTextField = "Code")]
		[DisplayName("Cmp")]
		[DefaultField(1)]
		public string CompanyCode { get; set; }
		[DisplayName("B#")]
		[DefaultField(3)]
		public object BatchNumber { get; set; }
		[EditColumnTemplate]
		[HtmlTitle("Batch Name")]
		public string Name { get; set; }
		[DisplayName("#")]
		[HtmlTitle("Loans in Batch")]
		public object LoansCount { get; set; }
		[SortField(0, SortDirection.Descending)]
		[DefaultField(2)]
		[DisplayName("Created")]
		[DisplayFormat(DataFormatString = "{0:MM/dd/yyyy}")]
		public object DateCreated { get; set; }
		[DisplayName("Rec")]
		[EditColumnTemplate]
		public object Recourse { get; set; }
		[DisplayName("Disc")]
		[EditColumnTemplate]
		public object Discount { get; set; }
	}
	#endregion

	#region t_Companies

	////////////////////////////////////////////////////////////////////////////////////////////////////
	/// <summary>	Company. </summary>
	///
	/// <remarks>	Dimon, 12/21/2010. </remarks>
	////////////////////////////////////////////////////////////////////////////////////////////////////

	[MetadataType(typeof(t_CompanyMetaData))]
	public partial class t_Company { }

	////////////////////////////////////////////////////////////////////////////////////////////////////
	/// <summary>	Company meta data. </summary>
	///
	/// <remarks>	Dimon, 12/21/2010. </remarks>
	////////////////////////////////////////////////////////////////////////////////////////////////////

	public class t_CompanyMetaData {
		[SortField(0)]
		public object Code;
	}
	#endregion

	#region v_TruthInLending

	////////////////////////////////////////////////////////////////////////////////////////////////////
	/// <summary>	V truth in lending. </summary>
	///
	/// <remarks>	Dimon, 12/21/2010. </remarks>
	////////////////////////////////////////////////////////////////////////////////////////////////////

	[MetadataType(typeof(v_TruthInLendingMetaData))]
	public partial class v_TruthInLending { }

	////////////////////////////////////////////////////////////////////////////////////////////////////
	/// <summary>	V truth in lending meta data. </summary>
	///
	/// <remarks>	Dimon, 12/21/2010. </remarks>
	////////////////////////////////////////////////////////////////////////////////////////////////////

	[SelectTable("LoanID=0")]
	[UpdateTable(typeof(v_BuyersOrder_Update))]
	[DeleteTable(typeof(v_Loan_Delete))]
	public partial class v_TruthInLendingMetaData {
		[SortField(0)]
		[DefaultField(0)]
		[ClientKey]
		public object LoanID;
		[EditColumnTemplate(Template = JQueryEditTemplates.dropdown, LookUpFieldName = "StatusID", IsAdd = false, IsEditAll = true)]
		public object Status;
		[DisplayName("PBID")]
		public object PurchaseBatchID { get; set; }
		[DisplayName("PT")]
		public object PaymentTypeCode { get; set; }
		[DisplayName("IT")]
		public object InterestTypeName { get; set; }
		[DisplayFormat(DataFormatString = "{0:MM/dd/yyyy}")]
		[DisplayName("1stPD")]
		public object FirstPaymentDate { get; set; }
		[DisplayName("DCC")]
		[EditColumnTemplate(typeof(ts_DayCountConvention),typeof(v_TruthInLending),LookUpFieldName="DayCountConventionName")]
		public object DayCountConventionName { get; set; }
		[EditColumnTemplate]
		public object CarYear;
	}
	#endregion

	#region usix_v_Payment

	////////////////////////////////////////////////////////////////////////////////////////////////////
	/// <summary>	Usix v payment. </summary>
	///
	/// <remarks>	Dimon, 12/21/2010. </remarks>
	////////////////////////////////////////////////////////////////////////////////////////////////////

	[MetadataType(typeof(usix_v_PaymentMetaData))]
	public partial class usix_v_Payment { }

	////////////////////////////////////////////////////////////////////////////////////////////////////
	/// <summary>	Usix v payment meta data. </summary>
	///
	/// <remarks>	Dimon, 12/21/2010. </remarks>
	////////////////////////////////////////////////////////////////////////////////////////////////////

	[SelectTable()]
	public partial class usix_v_PaymentMetaData {
		[DisplayName("Date")]
		[DefaultField(0)]
		[DisplayFormat(DataFormatString="{0:MM/dd/yyyy}")]
		[SortField(0, SortDirection.Descending)]
		public object Payment_Date { get; set; }
		[DisplayName("Amount"), DefaultField(1)]
		public object Payment_Amount { get; set; }
		[DefaultField(2)]
		public object DPD { get; set; }
	}
	#endregion

	#region v_Payment_USIX

	////////////////////////////////////////////////////////////////////////////////////////////////////
	/// <summary>	V payment usix. </summary>
	///
	/// <remarks>	Dimon, 12/21/2010. </remarks>
	////////////////////////////////////////////////////////////////////////////////////////////////////

	[MetadataType(typeof(v_Payment_USIXMetaData))]
	public partial class v_Payment_USIX { }

	////////////////////////////////////////////////////////////////////////////////////////////////////
	/// <summary>	V payment usix meta data. </summary>
	///
	/// <remarks>	Dimon, 12/21/2010. </remarks>
	////////////////////////////////////////////////////////////////////////////////////////////////////

	[SelectTable()]
	public partial class v_Payment_USIXMetaData {
		[DisplayName("Date")]
		[DefaultField(0)]
		[DisplayFormat(DataFormatString = "{0:MM/dd/yyyy}")]
		[SortField(0, SortDirection.Descending)]
		public object Payment_Date { get; set; }
		[DisplayName("Amount"), DefaultField(1)]
		public object Payment_Amount { get; set; }
		[DefaultField(2)]
		public object DPD { get; set; }
	}
	#endregion

	#region t_Loan

	////////////////////////////////////////////////////////////////////////////////////////////////////
	/// <summary>	Loan. </summary>
	///
	/// <remarks>	Dimon, 12/21/2010. </remarks>
	////////////////////////////////////////////////////////////////////////////////////////////////////

	public partial class t_Loan {
		[Column(Name="ID", Storage = "_ID", AutoSync = AutoSync.OnInsert, DbType = "Int NOT NULL IDENTITY")]
		public int LoanID {
			get { return this.ID; }
			set { ID = value; }
		}
	}
	#endregion

	#region PaymentWaterFall

	////////////////////////////////////////////////////////////////////////////////////////////////////
	/// <summary>	Ts payment water fall. </summary>
	///
	/// <remarks>	Dimon, 12/21/2010. </remarks>
	////////////////////////////////////////////////////////////////////////////////////////////////////

	[MetadataType(typeof(ts_PaymentWaterFallMetaData))]
	public partial class ts_PaymentWaterFall {
		public string ShowFile {
			get {// TODO: onclick leaks in IE
				string onClick =
					"<IMG src='/images/Buttons/Excel.gif' onclick='event.cancelBubble=true;Dimok.FindMainMenu().openWindow(\"/Manager/webservices/Payments.asmx/ShowWaterFall?ID=" + ID + "&\"+new Date().valueOf(),\"WATERFALL_" + ID + "\")' />";
				return this.Attachment != null ? onClick : "";
			}
		}
	}

	////////////////////////////////////////////////////////////////////////////////////////////////////
	/// <summary>	Ts payment water fall meta data. </summary>
	///
	/// <remarks>	Dimon, 12/21/2010. </remarks>
	////////////////////////////////////////////////////////////////////////////////////////////////////

	[SelectTable(true)]
	[UpdateTable(typeof(ts_PaymentWaterFall))]
	[DeleteTable]
	[InsertTable]
	public partial class ts_PaymentWaterFallMetaData {
		[DefaultField(0)]
		[SortField(0)]
		[ClientKey]
		[EditColumnTemplate]
		public object ID { get; set; }
		[DefaultField(1)]
		[EditColumnTemplate]
		public object Name { get; set; }
		[EditColumnTemplate]
		public object Description { get; set; }
	}
	#endregion

	#region v_ContractHolders

	////////////////////////////////////////////////////////////////////////////////////////////////////
	/// <summary>	V contract holder. </summary>
	///
	/// <remarks>	Dimon, 12/21/2010. </remarks>
	////////////////////////////////////////////////////////////////////////////////////////////////////

	[MetadataType(typeof(v_ContractHolderMetaData))]
	public partial class v_ContractHolder{}

	////////////////////////////////////////////////////////////////////////////////////////////////////
	/// <summary>	V contract holder meta data. </summary>
	///
	/// <remarks>	Dimon, 12/21/2010. </remarks>
	////////////////////////////////////////////////////////////////////////////////////////////////////

	[SelectTable(true)]
	[UpdateTable(typeof(t_ContractHolder))]
	[DeleteTable]
	[InsertTable]
	public class v_ContractHolderMetaData {
		[DefaultField(0)]
		public object ID;
		[DefaultField(10)]
		[DisplayName("Name")]
		[SortField(10)]
		[EditColumnTemplate]
		public object Name { get; set; }
		[DefaultField(15)]
		[DisplayName("Nick")]
		[EditColumnTemplate]
		public object Nick { get; set; }
		[DefaultField(20)]
		[DisplayName("CC")]
		public object ConditionsCode { get; set; }
		[DefaultField(40)]
		[DisplayName("Dealer")]
		[EditColumnTemplate(typeof(v_Dealer), typeof(v_ContractHolder), LookUpFieldName = "DealerID", LookUpTextField = "ShortName")]
		public object DealerName { get; set; }
		[DefaultField(50)]
		[DisplayName("St")]
		[EditColumnTemplate(typeof(ts_State), typeof(v_ContractHolder), LookUpFieldName = "State", LookUpTextField = "StateCode", LookUpValueField = "StateCode")]
		public object State { get; set; }
	}
	#endregion

	#region PaymentTransactions

	////////////////////////////////////////////////////////////////////////////////////////////////////
	/// <summary>	V payment transaction. </summary>
	///
	/// <remarks>	Dimon, 12/21/2010. </remarks>
	////////////////////////////////////////////////////////////////////////////////////////////////////

	[MetadataType(typeof(v_PaymentTransactionMetaData))]
	public partial class v_PaymentTransaction { }

	////////////////////////////////////////////////////////////////////////////////////////////////////
	/// <summary>	V payment transaction meta data. </summary>
	///
	/// <remarks>	Dimon, 12/21/2010. </remarks>
	////////////////////////////////////////////////////////////////////////////////////////////////////

	[SelectTable()]
	[UpdateTable(typeof(t_PaymentTransaction))]
	[DeleteTable]
	[InsertTable]
	public partial class v_PaymentTransactionMetaData {
		[DefaultField(0)]
		[SortField(0, SortDirection.Descending)]
		[ClientKey]
		public object ID { get; set; }
		[DisplayName("PID")]
		public object PaymentID { get; set; }
		[DisplayName("T")]
		[DefaultField(1)]
		public object TypeCode { get; set; }
		[DefaultField(2)]
		public object Amount { get; set; }
	}
	#endregion

	#region Payments

	////////////////////////////////////////////////////////////////////////////////////////////////////
	/// <summary>	V payment. </summary>
	///
	/// <remarks>	Dimon, 12/21/2010. </remarks>
	////////////////////////////////////////////////////////////////////////////////////////////////////

	[MetadataType(typeof(v_PaymentMetaData))]
	public partial class v_Payment { }

	////////////////////////////////////////////////////////////////////////////////////////////////////
	/// <summary>	V payment meta data. </summary>
	///
	/// <remarks>	Dimon, 12/21/2010. </remarks>
	////////////////////////////////////////////////////////////////////////////////////////////////////

	[SelectTable()]
	[UpdateTable(typeof(t_Payment))]
	[DeleteTable(typeof(t_Payment))]
	[InsertTable(typeof(v_Payment_ForInsert))]
	public partial class v_PaymentMetaData {
		[DefaultField(0)]
		[SortField(0, SortDirection.Descending)]
		[ClientKey]
		public object ID { get; set; }
		[DefaultField(1)]
		[DisplayFormat(DataFormatString = "{0:MM/dd/yyyy}")]
		[EditColumnTemplate]
		public object DatePaid { get; set; }
		[DefaultField(3)]
		[DisplayName("Amount")]
		[EditColumnTemplate]
		public object Amount { get; set; }
		[DefaultField(4)]
		public object Interest { get; set; }
		[DefaultField(5)]
		public object IntAddOn { get; set; }
		[DefaultField(6)]
		public object PrincipalBalance { get; set; }
		[DefaultField(7)]
		public object PaymentBalance { get; set; }
		[DefaultField(8)]
		public object PaymentNumber { get; set; }
		[DefaultField(9)]
		public object ExpectedBalance { get; set; }
		[DisplayName("Date Sched")]
		public object DateScheduled { get; set; }
		[DisplayFormat(DataFormatString = "{0:MM/dd/yyyy}")]
		public object DateNext { get; set; }
		[DetailKey]
		public object LoanID;
		[DisplayName("WF")]
		[EditColumnTemplate(typeof(ts_PaymentWaterFall),typeof(v_Payment),IsEditAll=true,LookUpFieldName="WaterFallID")]
		public object WaterFall { get; set; }
		[DisplayName("EP")]
		public object ExpectedPayment { get; set; }
		[DisplayName("DCC")]
		[EditColumnTemplate(typeof(ts_DayCountConvention), typeof(v_Payment), LookUpFieldName = "DayCountConventionID")]
		public object DayCountConventionName { get; set; }
	}
	#endregion

	////////////////////////////////////////////////////////////////////////////////////////////////////
	/// <summary>	V document. </summary>
	///
	/// <remarks>	Dimon, 12/21/2010. </remarks>
	////////////////////////////////////////////////////////////////////////////////////////////////////

	[MetadataType(typeof(v_DocumentMetaData))]
	partial class v_Document { }

	////////////////////////////////////////////////////////////////////////////////////////////////////
	/// <summary>	V document meta data. </summary>
	///
	/// <remarks>	Dimon, 12/21/2010. </remarks>
	////////////////////////////////////////////////////////////////////////////////////////////////////

	public class v_DocumentMetaData {
		[ClientKey]
		public object ID;
	}
	#endregion

}